window.onload = function () {
    const origin = `${window.location.protocol}//${window.location.hostname}`;
    // const origin = 'https://xxdt.dev.ganguomob.com';

    const url = `${origin}/api/`;

    function parseQueryString() {
        var str = window.location.search.slice(1);
        var arr = str.split('&');
        var obj = {};
    
        for (var i = 0; i < arr.length; i++) {
            // 一般参数字符串都经过编码，使用decodeURIComponent()方法将键和值转为原始值
            var item = arr[i].split('=');
            var key = decodeURIComponent(item[0]);
            var value = decodeURIComponent(item[1]);
            obj[key] = value;
        }
    
        return obj;
    }

    const id  = parseQueryString().id ? parseQueryString().id : '';

    new Vue({
        el: '#vm',
        data: {
            data: '',
        },
        methods: {
            fetchData() {
                axios.get(`${url}supplier/message/${id}`).then(res => {
                    this.data = res.data.data;
                    this.data.time = convertTime('YYYY-MM-DD hh:MM', res.data.data.created_at);
                }).catch(error => Toast(error.data.message, 300));
            },
        },
        mounted() {
            this.fetchData();
        },
    });
}
